package com.bruan.d4_local;

import java.time.LocalDate;

public class Test1_LocalDate {
    public static void main(String[] args) {
        LocalDate ld = LocalDate.now();//年月日
        System.out.println(ld);

        System.out.println("-----------------");
        //1. 获取对象信息
        int year = ld.getYear();
        int month = ld.getMonthValue();
        int day = ld.getDayOfYear();
        int dayOfYear = ld.getDayOfYear();//一年中的几天
        int dayOfWeek = ld.getDayOfWeek().getValue();
        System.out.println(year);
        System.out.println(month);
        System.out.println(day);
        System.out.println(dayOfYear);
        System.out.println(dayOfWeek);

        System.out.println("----------------");
        LocalDate ld2 = ld.withYear(2033).withMonth(12).plusYears(2);
        System.out.println(ld2.getYear());
        System.out.println(ld2.getMonthValue());

        System.out.println("----------------");
        LocalDate ld3 = LocalDate.of(2222,2,22);
        System.out.println(ld3);

        System.out.println("----------------");
        System.out.println(ld.equals(ld2));
        System.out.println(ld.isAfter(ld3));
        System.out.println(ld.isAfter(ld2));

    }
}
